(function(vc){

    vc.extends({
        propTypes: {
               callBackListener:vc.propTypes.string, //父组件名称
               callBackFunction:vc.propTypes.string //父组件监听方法
        },
        data:{
            addShopAuditInfo:{
                auditId:'',
shopId:'',
shopLogo:'',
storeId:'',
shopName:'',
shopDesc:'',
mapX:'',
mapY:'',
sendAddress:'',
returnAddress:'',
returnPerson:'',
returnLink:'',
state:'',
shopType:'',
openType:'',
areaCode:'',
auditOpinion:'',
applyOpinion:'',
statusCd:'',

            }
        },
         _initMethod:function(){

         },
         _initEvent:function(){
            vc.on('addShopAudit','openAddShopAuditModal',function(){
                $('#addShopAuditModel').modal('show');
            });
        },
        methods:{
            addShopAuditValidate(){
                return vc.validate.validate({
                    addShopAuditInfo:vc.component.addShopAuditInfo
                },{
                    'addShopAuditInfo.auditId':[
{
                            limit:"required",
                            param:"",
                            errInfo:"审核ID不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"30",
                            errInfo:"审核ID不能超过30"
                        },
                    ],
'addShopAuditInfo.shopId':[
{
                            limit:"required",
                            param:"",
                            errInfo:"店铺ID不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"30",
                            errInfo:"店铺ID不能超过30"
                        },
                    ],
'addShopAuditInfo.shopLogo':[
{
                            limit:"required",
                            param:"",
                            errInfo:"店铺logo不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"1024",
                            errInfo:"店铺logo不能超过1024"
                        },
                    ],
'addShopAuditInfo.storeId':[
{
                            limit:"required",
                            param:"",
                            errInfo:"商户ID不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"30",
                            errInfo:"商户ID不能超过30"
                        },
                    ],
'addShopAuditInfo.shopName':[
{
                            limit:"required",
                            param:"",
                            errInfo:"店铺名称不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"128",
                            errInfo:"店铺名称不能超过128"
                        },
                    ],
'addShopAuditInfo.shopDesc':[
{
                            limit:"required",
                            param:"",
                            errInfo:"店铺描述不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"512",
                            errInfo:"店铺描述不能超过512"
                        },
                    ],
'addShopAuditInfo.mapX':[
{
                            limit:"required",
                            param:"",
                            errInfo:"地区不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"20",
                            errInfo:"地区不能超过20"
                        },
                    ],
'addShopAuditInfo.mapY':[
{
                            limit:"required",
                            param:"",
                            errInfo:"地区不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"20",
                            errInfo:"地区不能超过20"
                        },
                    ],
'addShopAuditInfo.sendAddress':[
{
                            limit:"required",
                            param:"",
                            errInfo:"发货地址不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"512",
                            errInfo:"发货地址不能超过512"
                        },
                    ],
'addShopAuditInfo.returnAddress':[
{
                            limit:"required",
                            param:"",
                            errInfo:"退货地址不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"512",
                            errInfo:"退货地址不能超过512"
                        },
                    ],
'addShopAuditInfo.returnPerson':[
{
                            limit:"required",
                            param:"",
                            errInfo:"退货联系人不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"512",
                            errInfo:"退货联系人不能超过512"
                        },
                    ],
'addShopAuditInfo.returnLink':[
{
                            limit:"required",
                            param:"",
                            errInfo:"退货联系电话不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"11",
                            errInfo:"退货联系电话不能超过11"
                        },
                    ],
'addShopAuditInfo.state':[
{
                            limit:"required",
                            param:"",
                            errInfo:"状态不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"12",
                            errInfo:"状态不能超过12"
                        },
                    ],
'addShopAuditInfo.shopType':[
{
                            limit:"required",
                            param:"",
                            errInfo:"店铺类型不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"30",
                            errInfo:"店铺类型不能超过30"
                        },
                    ],
'addShopAuditInfo.openType':[
{
                            limit:"required",
                            param:"",
                            errInfo:"开店类型不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"2",
                            errInfo:"开店类型不能超过2"
                        },
                    ],
'addShopAuditInfo.areaCode':[
{
                            limit:"required",
                            param:"",
                            errInfo:"地域编码不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"12",
                            errInfo:"地域编码不能超过12"
                        },
                    ],
'addShopAuditInfo.auditOpinion':[
{
                            limit:"required",
                            param:"",
                            errInfo:"审核意见不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"300",
                            errInfo:"审核意见不能超过300"
                        },
                    ],
'addShopAuditInfo.applyOpinion':[
{
                            limit:"required",
                            param:"",
                            errInfo:"申请原因不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"300",
                            errInfo:"申请原因不能超过300"
                        },
                    ],
'addShopAuditInfo.statusCd':[
{
                            limit:"required",
                            param:"",
                            errInfo:"数据状态不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"2",
                            errInfo:"数据状态不能超过2"
                        },
                    ],




                });
            },
            saveShopAuditInfo:function(){
                if(!vc.component.addShopAuditValidate()){
                    vc.toast(vc.validate.errInfo);

                    return ;
                }

                vc.component.addShopAuditInfo.caId = vc.getCurrentCommunity().caId;
                //不提交数据将数据 回调给侦听处理
                if(vc.notNull($props.callBackListener)){
                    vc.emit($props.callBackListener,$props.callBackFunction,vc.component.addShopAuditInfo);
                    $('#addShopAuditModel').modal('hide');
                    return ;
                }
                vc.http.apiPost(
                    '/shopAudit/saveShopAudit',
                    JSON.stringify(vc.component.addShopAuditInfo),
                    {
                        emulateJSON:true
                     },
                     function(json,res){
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            $('#addShopAuditModel').modal('hide');
                            vc.component.clearAddShopAuditInfo();
                            vc.emit('shopAuditManage','listShopAudit',{});

                            return ;
                        }
                        vc.message(_json.msg);

                     },
                     function(errInfo,error){
                        console.log('请求失败处理');

                        vc.message(errInfo);

                     });
            },
            clearAddShopAuditInfo:function(){
                vc.component.addShopAuditInfo = {
                                            auditId:'',
shopId:'',
shopLogo:'',
storeId:'',
shopName:'',
shopDesc:'',
mapX:'',
mapY:'',
sendAddress:'',
returnAddress:'',
returnPerson:'',
returnLink:'',
state:'',
shopType:'',
openType:'',
areaCode:'',
auditOpinion:'',
applyOpinion:'',
statusCd:'',

                                        };
            }
        }
    });

})(window.vc);
